package com.wis.mapper;

import com.wis.entity.TeacherEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherMapper {
    @Select("SELECT * FROM teacher LIMIT #{limit} OFFSET #{offset}")
    List<TeacherEntity> selectTeacherByName(@Param("limit") int limit, @Param("offset") int offset);

    @Insert("INSERT INTO teacher (name, free_money, charge_money) VALUES (#{name}, #{freeMoney}, #{chargeMoney})")
    int addTeacher(TeacherEntity teacher);

    @Delete("DELETE FROM teacher WHERE id = #{id}")
    int delTeacher(@Param("id") int id);

    @Update("UPDATE teacher SET name = #{name} WHERE id = #{id}")
    int updateTeacher(TeacherEntity teacher);


    // 查询姓名是否存在
    @Select("SELECT COUNT(*) FROM teacher WHERE name = #{name}")
    int isExist(@Param("name") String name);

    // 查询单个老师
    @Select("SELECT * FROM teacher WHERE name = #{name}")
    TeacherEntity showTeacherByName(@Param("name") String name);
}
